#ifndef PW_PBL_CHARS_HPP
#define PW_PBL_CHARS_HPP

#include "IntFor.hpp"
#include "Meta/VHStr.hpp"
#include "pw_pbl/Math.hpp"

namespace pw_pbl
{
	template <size_t... P>
	struct Chars;

	/// 固定长度头部字符串
	/// @tparam LEN_BYTES 长度占用的字节数，注意：多字节时仍按单字节对齐
	/// @tparam N 最长字符个数
	template <size_t LEN_BYTES, size_t N>
	struct [[gnu::packed]] Chars<LEN_BYTES, N>
	{
		static_assert(LEN_BYTES != 0 && Math::IsPow2(LEN_BYTES));
		UIntFor::Size<LEN_BYTES> len;
		char buf[N];

		constexpr operator std::string_view() const { return {buf, len}; }
	};

	/// 变长头部字符串
	/// @tparam N 总字节数
	template <size_t N>
	struct Chars<N>
	{
		Meta::VHStr<char, N> str;
	};

} // namespace pw_pbl

#endif // PW_PBL_CHARS_HPP
